import copy
import pytest
import allure
from utils.request_handler import RequestHandler
from utils.yaml_handler import yamler
from utils.render_template_handler import rend_template_any
from hotloads.debugtalk import DebugTalk
from config import settings

login_data = yamler.read_data(settings.CASE_PATH / "xxxtest_login.yml")
info_data = yamler.read_data(settings.CASE_PATH / "xxxtest_info.yml")


@allure.feature(login_data[0]["feature"])
class TestUser(object):
    @pytest.mark.parametrize("case_info", login_data)
    @allure.story(login_data[0]["story"])
    def test_login(self, case_info):
        allure.dynamic.title(case_info["title"])
        res = RequestHandler(DebugTalk()).get_request_data(case_info)

    @pytest.mark.parametrize("case_info", info_data)
    @allure.story(info_data[0]["story"])
    def test_info(self, case_info):
        allure.dynamic.title(case_info["title"])
        copy_value = copy.deepcopy(case_info)
        case_info = rend_template_any(copy_value)
        res = RequestHandler(DebugTalk()).get_request_data(case_info)
